﻿<controls:ChildWindow x:Class="Reactor.Client.Views.AdoptServiceWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
    xmlns:local="clr-namespace:Reactor.Client.Controls" xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit" mc:Ignorable="d"
    DataContext="{Binding AdoptService, Source={StaticResource Locator}}"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <local:BusyIndicator x:Name="busyIndicator" BusyContent="{Binding Path=ApplicationStrings.BusyIndicatorSendingAdoptionCommand, Source={StaticResource ResourceWrapper}}"
                             IsBusy="{Binding IsSendingAdoptionCommand}" Margin="10">
            <Controls:DataForm x:Name="adoptionForm" 
                                  CurrentItem="{Binding AdoptionModel}"
                                  IsEnabled="{Binding IsSendingAdoptionCommand, Converter={StaticResource NotOperatorValueConverter}}"
                                  AutoEdit="True" 
                                  Header="Choose the service the Core is to adopt." 
                                  Style="{StaticResource DataFormStyle}">
                <Controls:DataForm.EditTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <Controls:DataField>
                                <TextBlock Text="{Binding CoreName, Mode=TwoWay}" />
                            </Controls:DataField>
                            <Controls:DataField>
                                <ComboBox DisplayMemberPath="DisplayName"
                                          ItemsSource="{Binding ServicePackages}"
                                          SelectedItem="{Binding SelectedServicePackage, Mode=TwoWay}" >
                                </ComboBox>
                            </Controls:DataField>
                        </StackPanel>
                    </DataTemplate>
                </Controls:DataForm.EditTemplate>
            </Controls:DataForm>
        </local:BusyIndicator>

        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
            <Button Content="{Binding Path=ApplicationStrings.OKButton, Source={StaticResource ResourceWrapper}}" 
                    Style="{StaticResource RegisterLoginButtonStyle}" Command="{Binding SendAdoptionCommand}"
                    IsEnabled="{Binding IsSendingAdoptionCommand, Converter={StaticResource NotOperatorValueConverter}}" />
            
            <Button Content="{Binding Path=ApplicationStrings.CancelButton, Source={StaticResource ResourceWrapper}}" 
                    Style="{StaticResource RegisterLoginButtonStyle}" Command="{Binding CancelAdoption}" />
        </StackPanel>
    </Grid>
</controls:ChildWindow>
